#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
#define ll long long
ll T,n,m,V,L;
struct node{
    double d;
    ll v,a;
} c[N];
double cc[N];
double maxn=-1;;
bool cct[N];
struct nodee{
    double l,r;
    double sz;
    int le,re;
} aa[N];
ll cnt=0;
ll ans1=0;
ll ans2=0;
bool flag;
vector<ll> g[N];
bool vis[N];
ll summc=0;

/*ll fa[N];
inline ll find(ll x){
    if(fa[x]!=x){
        fa[x]=find(fa[x]);
    }
    return fa[x];
}
inline void merge(ll x,ll y){
    ll rtx=find(x),rty=find(y);
    if(rtx==rty) return;
    fa[rtx]=rty;
}*/

inline bool cmp(nodee x,nodee y){
    if(x.l==y.l) return x.r<y.r;
    return x.l<y.l;
}

inline bool cmp2(vector<ll> x,vector<ll> y){
    return x.size()>y.size();
}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%lld",&T);
    while(T--){
        memset(vis,false,sizeof(vis));
        summc=0;
        ans1=0;
        ans2=0;
        flag=true;
        cnt=0;
        scanf("%lld%lld%lld%lld",&n,&m,&L,&V);
        memset(cct,false,sizeof(cct));
        for(int i=1;i<=m;i++){
            g[i].clear();
        }
        for(int i=1;i<=n;i++){
            scanf("%lf%lld%lld",&c[i].d,&c[i].v,&c[i].a);
            //gg[i].clear();
            if(c[i].a!=0) flag=false;
            //fa[i]=i;
        }
        for(int i=1;i<=m;i++){
            scanf("%lf",&cc[i]);
            maxn=max(maxn,cc[i]);
            cct[int(cc[i])]=true;
        }
        /*if(flag){
            for(int i=1;i<=n;i++){
                double a=double(c[i].a);
                double v=double(c[i].v);
                double d=c[i].d;
                if(a==0){
                    if(v>V&&d<=maxn){
                        ans1++;
                        aa[++cnt].l=d;
                        aa[cnt].r=double(L);
                        aa[cnt].sz=aa[cnt].r-aa[cnt].l;
                        aa[cnt].le=aa[cnt].re=1;
                    }
                }
            }
        }*/
        for(int i=1;i<=n;i++){
            double a=double(c[i].a);
            double v=double(c[i].v);
            double d=c[i].d;
            if(a==0){
                if(v>V&&d<=maxn){
                    ans1++;
                    aa[++cnt].l=d;
                    aa[cnt].r=double(L);
                    aa[cnt].sz=aa[cnt].r-aa[cnt].l;
                    aa[cnt].le=aa[cnt].re=1;
                }
            }else if(a>0){
                if(v>V&&d<=maxn){
                    ans1++;
                    aa[++cnt].l=d;
                    aa[cnt].r=double(L);
                    aa[cnt].sz=aa[cnt].r-aa[cnt].l;
                    aa[cnt].le=aa[cnt].re=1;
                    continue;
                }
                double pos=(V*V-v*v)/(2*a);
                pos+=d;
                if(pos<=maxn){
                    ans1++;
                    aa[++cnt].l=pos;
                    aa[cnt].r=double(L);
                    aa[cnt].sz=aa[cnt].r-aa[cnt].l;
                    aa[cnt].le=0;
                    aa[cnt].re=1;
                }
            }else if(a<0){
                if(v<=V){
                    continue;
                }
                double pos=(v*v-V*V)/(2*abs(a));
                pos+=d;
                for(int i=ceil(d);i<=floor(pos);i++){
                    if(cct[i]){
                        ans1++;
                        aa[++cnt].l=d;
                        aa[cnt].r=pos;
                        aa[cnt].sz=aa[cnt].r-aa[cnt].l;
                        aa[cnt].re=1;
                        aa[cnt].re=0;
                        break;
                    }
                }
                //cout<<d<<" "<<pos<<endl;
            }
        }
        sort(aa+1,aa+1+cnt,cmp);
        for(int i=1;i<=cnt;i++){
            //cout<<aa[i].l<<" "<<aa[i].r<<" "<<aa[i].sz<<endl;
            int posa,posb;
            posa=upper_bound(cc+1,cc+1+m,aa[i].l)-cc;
            posb=lower_bound(cc+1,cc+1+m,aa[i].r)-cc;
            //cout<<posa<<" "<<posb<<endl;
            for(int j=posa;j<=posb;j++){
                g[j].push_back(i);
            }
        }
        sort(g+1,g+1+m,cmp2);
        for(int i=1;i<=m;i++){
            //cout<<g[i].size()<<endl;
            bool fllag=true;
            for(int j=0;j<g[i].size();j++){
                int v=g[i][j];
                //cout<<v<<endl;
                if(!vis[v]){
                    vis[v]=true;
                    summc++;
                    fllag=false;
                }
            }
            if(fllag) ans2++;
            if(summc==cnt){
                ans2+=m-i;
                break;
            }
        }
        printf("%lld %lld\n",ans1,ans2);
    }
    return 0;
}